package test.api.gridfs;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

	/**
	 * <p>Class       : test.encoder.EncoderThread
	 * <p>Descdription: 验证Encoder对CPU的耗费情况
	 * @author  顾力行-gulixing@msn.com
	 * @version 1.0.0
	 */
	public class GridFSThread extends Thread {
		private String fileUri;
		
		private int count;
		
	public GridFSThread(String fileUri) {
		this.fileUri = fileUri;
	}
	/**
	 * Logger for this class
	 */
	private static final Logger logger = LoggerFactory.getLogger(GridFSThread.class);
	
//	    BCryptPasswordEncoder bpe = new BCryptPasswordEncoder();
	    
	    @Override
	    public void run() {
	    	GridFSDao fsdao = new GridFSDao();
	    	while(true){
	    		if(count % 1000==0){
	    			logger.info("{}存入{}个文件",this.getName(),count);
	    		}
	    		try {
					fsdao.save(fileUri);
					++count;
				} catch (IOException e1) {
					e1.printStackTrace();
				}
//	    		try {
//                    Thread.sleep(10);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//	    		logger.info(this.getId()+" | "+bpe.encode(RandomStringUtils.randomAlphabetic(6)));
	    	}
	    }
	
	
}

